/**
 * 
 */
package com.eagle.coders.core.dynamic.compiler;

import java.io.IOException;
import java.net.URI;

import javax.tools.SimpleJavaFileObject;

/**
 * @author Anees
 * 
 */
public class DynamicJavaStringSourceObject extends SimpleJavaFileObject {

	private String qualifiedName;
	private String code;

	/**
	 * 
	 * @param name
	 * @param code
	 */
	public DynamicJavaStringSourceObject(String name, String code) {
		super(URI.create("string:///" + name.replace('.', '/')
				+ Kind.SOURCE.extension), Kind.SOURCE);

		this.qualifiedName = name;
		this.code = code;
	}
	
	@Override
	public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
		// TODO Auto-generated method stub
		return code;
	}
	
	/**
	 * 
	 * @return
	 */
	public String getQualifiedName() {
		return qualifiedName;
	}
	
	/**
	 * 
	 * @param qualifiedName
	 */
	public void setQualifiedName(String qualifiedName) {
		this.qualifiedName = qualifiedName;
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}
}